package model

import (
	"gorm.io/gorm"
	"time"
)

type Hospital struct {
	ID            uint      `gorm:"primaryKey;autoIncrement" json:"id"`
	Name          string    `gorm:"type:varchar(100);not null" json:"name"`
	Logo          string    `gorm:"type:varchar(255)" json:"logo"`
	Level         string    `gorm:"type:varchar(50)" json:"level"` // 如 "三级甲等"
	Address       string    `gorm:"type:varchar(255)" json:"address"`
	Phone         string    `gorm:"type:varchar(20)" json:"phone"`
	Introduction  string    `gorm:"type:text" json:"introduction"`
	Route         string    `gorm:"type:text" json:"route"`
	BusinessHours string    `gorm:"type:varchar(100)" json:"business_hours"` // 如 "08:00-17:30"
	Latitude      float64   `gorm:"type:decimal(10,7)" json:"latitude"`
	Longitude     float64   `gorm:"type:decimal(10,7)" json:"longitude"`
	Status        int32     `gorm:"default:1" json:"status"` // 1: 正常, 0: 停用
	CreatedAt     time.Time `json:"created_at,omitempty"`
	UpdatedAt     time.Time `json:"updated_at,omitempty"`
}

// GetByID 根据 ID 获取医院详情
func (h *Hospital) GetByID(db *gorm.DB, id uint) error {
	return db.Where("id = ? AND status = 1", id).First(h).Error
}
